Group Chat
note you can use v chat test server base url is
http://170.178.195.150:81/api/v1/
1 - Create Group chat
- URL: {{baseUrl}}room/group
- Method: POST
- Content-Type:
form-data
to send image of user in file parameter - Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"peerEmails":["user1","user2"],
"title":"title",
"file":"group image"
}
Parameter | Required | Description |
---|---|---|
peerEmails | true | users emails to create group |
title | true | user hashed password |
file | false | group image if null will group default image |
Example response:
{
"success": true,
"data": {
"_id": "61b4fcd10a994d17bc5913a1",
"blockerId": null,
"groupSetting": null,
"updatedAt": 1639251153404,
"creatorId": "61b4fb287ba4900ae8abe70c",
"roomType": "single",
"isOnline": 0,
"title": "user2",
"peerId": "61b4fb3b7ba4900ae8abe710",
"peerEmail": "user2",
"thumbImage": "default_user_image.png",
"roomMembersCount": 2,
"isMute": 0,
"lastMessage": {
"_id": "61b4fcd10a994d17bc5913ab",
"messageType": "text",
"messageAttachment": null,
"createdAt": 1639251153399,
"content": "first",
"senderId": "61b4fb287ba4900ae8abe70c",
"senderName": "user1",
"senderImageThumb": "default_user_image.png",
"roomId": "61b4fcd10a994d17bc5913a1"
},
"unReadCount": 0
}
}
2 - Add member to group
- URL: {{baseUrl}}room/add-member
- Method: POST
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"peersId": ["userEmail1","userEmail2"],
"roomId":"61b8697ab2171a4f04599746"
}
Parameter | Required | Description |
---|---|---|
peersId | true | users emails to join group |
roomId | true | group id |
Example response:
{
"success": true,
"data": "users has been added successfully"
}
3 - Update group info
- URL: {{baseUrl}}room/update-group-info
- Method: POST
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"groupName": ["userEmail1","userEmail2"],
"roomId":"61b8697ab2171a4f04599746",
"file":"61b8697ab2171a4f04599746"
}
Parameter | Required | Description |
---|---|---|
groupName | false | new group name |
roomId | true | group id |
file | false | new group image |
Example response:
{
"success": true,
"data": {
"name": "asdfasdf",
"imageThumb": "GROUP_CHAT_746129cc-6175-4da8-90be-3f0a6b4aa528_THUMB.jpg"
}
}
note you can use this api for only change group title and don't pass file so title will only change
4 - Update group member state (admin or member)
- URL: {{baseUrl}}room/update-member-state
- Method: POST
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"roomId":"61b77ee9de54ab57fc69884e",
"peerId":"61b52ae4fa536061acc04860",
"state":"member"
}
Parameter | Required | Description |
---|---|---|
peerId | true | peer id |
roomId | true | group id |
state | true | only member or admin are valid |
Example response:
{
"success": true,
"data": "Downgrade"
}
5 - Get Room Members
- URL: {{baseUrl}}room/group-members
- Method: GET
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"lastIndex":1,
"roomId":"61b52ae4fa536061acc04860"
}
Parameter | Required | Description |
---|---|---|
lastIndex | true | if 1 that mean get first 20 users in this group |
roomId | true | group id |
lastIndex
used to paginate users you need to increase it by 1 to get next page
Example response:
{
"success": true,
"data": [
{
"_id": "61b52ae4fa536061acc04860",
"imageThumb": "default_user_image.png",
"email": "user2",
"name": "user2",
"role": "member"
},
{
"_id": "61b52afffa536061acc04864",
"imageThumb": "default_user_image.png",
"email": "user1",
"name": "user1",
"role": "admin"
}
]
}
6 - Kick member
- URL: {{baseUrl}}room/kick-member
- Method: POST
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"roomId":"61b7c25549486b34280e800e",
"peerId":"61b52ae4fa536061acc04860"
}
Parameter | Required | Description |
---|---|---|
peerId | true | peer id to kick |
roomId | true | group id |
you must be admin to perform this action
Example response:
{
"success": true,
"data": "kicked successfully"
}
7 - Leave group chat
- URL: {{baseUrl}}room/kick-member
- Method: POST
- Content-Type: JSON
- Authentication: Bearer token is required in header in
authorization : Bearer yourToken
- Example request data:
{
"groupId":"61b5eedf1b9f0c346cda18ef"
}
Parameter | Required | Description |
---|---|---|
groupId | true | group id |
you must be in group to perform this action
Example response:
{
"success": true,
"data": "leaved successfully"
}